import tornado.web
import tornado.websocket
conndict = {}
class WebsockHandler(tornado.websocket.WebSocketHandler):
    # 跨域支持
    def check_origin(self,origin):
        return True
    #建立连接
    def open(self):
        # 获取参数
        id = int(self.get_query_argument('id'))
        # 存储链接
        conndict[id] = self

    def on_message(self,mes):
        print(mes)
    def on_close(self):
        pass

class TTHandler(tornado.web.RequestHandler):
    def get(self):
        mes = self.get_query_argument("mes")
        id = int(self.get_query_argument("id"))
        conndict[id].write_message(mes)